As this is the first set exercises in this workshop, it is relatively easy and short. Its purpose is also to get used to this exercise format.

You can find the solutions for this exercise and all other exercises in the ./solutions folder in the repo/directory that contains the course materials. You can easily copy code from these solution files by clicking on the small blue clipboard icon in the upper right corner of the solution boxes showing the code.

For working on the exercises, we suggest that you write R scripts (one per set of exercises or a combined one for the whole course) and store them in the ./MY_CODE folder contained in the course materials. This folder already contains a script stub called my_script.R which you can use for getting started.

NB: For the code from the solutions to work, you have to make sure that your script uses the root directory of the course materials as working directory. You can check the current working directory with getwd() and set it with setwd() accordingly. If you work with RStudio, you can also simply open the tidyverse-workshop-esra-2021.Rproj file. In that case, the correct to the working directory is already set.

That being said, let’s delve into the exercises:

1

Please install and/or load the tidyverse package.
We always recommend using the easypackages packages, which can be installed with the command install.packages("easypackages"). After loading the package with library(easypackages) you can load and install packages (if necessary) with one command: easypackages::packages("fancy_package_1", "fancy_package_2", ...)

2

Load the data set named USArrests that is built into R and print it.
You first need to load the data into your environment using the data() command. Then you can either just run the name of the data set as a command or use the print() function.

3

Now, convert the data to a tibble and print it. Compare it to the previous output.
You need the as_tibble() function from the tibble package here.

4

Have a look at the tibble using the function glimpse() from the dplyr package. Compare it to the previous outputs.
The argument that you need to provide to glimpse() is the name of the dataframe/tibble.

5

Finally, reload the data, convert it to a tibble, and use dplyr::glimpse() in one combined %>%-workflow.
Remember that the data object precedes the function call: x %>% f(.)